<%--
  Created by IntelliJ IDEA.
  User: JD
  Date: 2023/9/20
  Time: 14:59
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" +
            request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="<%=basePath%>static/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="<%=basePath%>static/css/font.css">
    <link rel="stylesheet" href="<%=basePath%>static/css/xadmin.css">
    <script type="text/javascript" src="<%=basePath%>static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="orderid" class="layui-form-label">
                <span class="x-red">*</span>订单id
            </label>
            <div class="layui-input-inline">
                <input type="text" id="orderid" name="orderid" readonly
                       autocomplete="off" class="layui-input" value="${order.orderid}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="userid" class="layui-form-label">
                用户id
            </label>
            <div class="layui-input-inline">
                <input type="userid" id="userid" name="userid" readonly
                       autocomplete="off" class="layui-input" value="${order.userid}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="ticketid" class="layui-form-label">
                票id
            </label>
            <div class="layui-input-inline">
                <input type="ticketid" id="ticketid" name="ticketid" readonly
                       autocomplete="off" class="layui-input" value="${order.ticketid}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="num" class="layui-form-label">
                购票数量
            </label>
            <div class="layui-input-inline">
                <input type="num" id="num" name="num"
                       autocomplete="off" class="layui-input" value="${order.num}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="sumprice" class="layui-form-label">
                订单价格
            </label>
            <div class="layui-input-inline">
                <input type="sumprice" id="sumprice" name="sumprice"
                       autocomplete="off" class="layui-input" value="${order.sumprice}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label for="ordertime" class="layui-form-label">订单时间</label>
                <div class="layui-input-inline">
                    <input type="datetime-local" class="layui-input" id="ordertime" placeholder="yyyy-MM-dd"
                           value="<fmt:formatDate value="${order.ordertime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" id="L_repass" type="button">
                修改
            </button>
        </div>
    </form>
</div>
</body>
<script type="text/javascript">
    $(document).on('click', '#L_repass', function() {
        submit();
    });
    function submit(){
        let order = {
            orderid: $("#orderid").val(),
            userid: $("#userid").val(),
            ticketid: $("#ticketid").val(),
            num: $("#num").val(),
            sumprice: $("#sumprice").val(),
            ordertime: $("#ordertime").val(),
        };
        console.log(order)
        $.ajax({
            url: "/order/updateOrder",
            type: "post",
            datatype: "json",
            contentType: "application/json",
            data: JSON.stringify(order),
            success: function (data){
                // console.log(data);
                layer.msg(data.message, {icon: 2});
                window.parent.location.reload();//刷新父页面
                parent.layer.close(layer.index);//关闭弹出层
                // data.code === 200 ? location.href = data.url : location.reload();
            },
            error: function (data){
                alert("失败！");
            }
        })
    }
</script>
</html>
